//
//  JMElectricDoorCell.m
//  OpenSesame
//
//  Created by zhangjiaming on 15/12/29.
//  Copyright © 2015年 OpenSesame. All rights reserved.
//

#import "JMElectricDoorCell.h"

@implementation JMElectricDoorCell

- (void)awakeFromNib {
    // Initialization code
}

+ (JMElectricDoorCell *)cellWithTableView:(UITableView *)tableView {
    static NSString *ID = @"doorCell";
    JMElectricDoorCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[JMElectricDoorCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        CGFloat ratio = 75/39.0; // backImageView的宽高比
        // 设置10个高度的灰色
        UIView *headView = [[UIView alloc] init];
        headView.backgroundColor = JMColor(242, 242, 242);
        headView.frame = CGRectMake(0, 0, JMPhoneWidth, 10);
        [self.contentView addSubview:headView];
        
        // 设置背景
        UIImageView *backImageView = [[UIImageView alloc] init];
        self.backImageView = backImageView;
        backImageView.frame = CGRectMake(0, 10, JMPhoneWidth, JMPhoneWidth/ratio);
        [self.contentView addSubview:self.backImageView];
        self.height = backImageView.height + headView.height;
    }
    return self;
}
@end
